]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Don't try to focus destroyed actor
authorSebastian Keller <skeller@gnome.org>
Mon, 27 Apr 2026 20:53:59 +0000 (22:53 +0200)
committerSebastian Keller <skeller@gnome.org>
Mon, 27 Apr 2026 21:22:09 +0000 (23:22 +0200)
When `ungrabFocus()` is called after hiding a notification, the previous
focus actor might have already been destroyed and trying to focus it
will trigger a gjs error.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/work_items/9190
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4197>

js/ui/messageTray.js

index e593d0da715bf0fb30958cfbb2a89789ec88e1b0..7f39233808fc08c7cc5167808dde31f04ed4a6c1 100644 (file)
@@ -88,6 +88,10 @@ class FocusGrabber {
 
         this._prevKeyFocusActor = global.stage.get_key_focus();
 
+        this._prevKeyFocusActor?.connectObject('destroy', () => {
+            this._prevKeyFocusActor = null;
+        }, this);
+
         global.stage.connectObject('notify::key-focus',
             this._focusActorChanged.bind(this), this);
 
@@ -101,6 +105,8 @@ class FocusGrabber {
         if (!this._focused)
             return false;
 
+        this._prevKeyFocusActor?.disconnectObject(this);
+
         global.stage.disconnectObject(this);
 
         this._focused = false;